package com.redsoil.house.ui.capital.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.redsoil.house.R;
import com.redsoil.house.base.BaseViewHolderTSK;
import com.redsoil.house.model.bean.PropertyListVO;
import com.redsoil.house.model.http.api.ApiConstants;
import com.redsoil.house.utils.Util;
import com.redsoil.house.widget.glide.GlideRoundTransform;

import java.util.List;

/**
 * 作者：weidingqiang on 2018/12/16 11:52
 * 邮箱：weidingqiang@163.com
 */

public class CapitalPropertyAdapter extends BaseQuickAdapter<PropertyListVO.DataListBean,BaseViewHolderTSK> {

    public CapitalPropertyAdapter(int layoutResId, List<PropertyListVO.DataListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolderTSK helper, PropertyListVO.DataListBean item) {

        helper.setText(R.id.build_name_tv,item.getBuildingName());
        if(item.getTypeValue().equals("一栋")){
            helper.setVisible(R.id.build_number_tv,false);
        }else {
            helper.setVisible(R.id.build_number_tv,true);
            helper.setText(R.id.build_number_tv," # "+item.getRoomNum());
        }
        helper.setText(R.id.build_address_tv,item.getBuildingAddress());
        helper.setText(R.id.price_tv, Util.nfValue(item.getJbuyPrice())+"万円");//Util.nfValue(item.getJbuyPrice()/1000)
        helper.setText(R.id.rate_tv,item.getReturnRate()+"%");


        Glide.with(mContext)
                .load(ApiConstants.STATIC_FILE+item.getPicPath())
                .centerCrop()
                .transform(new CenterCrop(mContext), new GlideRoundTransform(mContext, 10))
                .into((ImageView)helper.getView(R.id.capital_property_item_img));
    }
}
